package com.windea.study.kotlin.game.tankwar2.model

import com.windea.study.kotlin.game.tankwar2.core.*
import com.windea.study.kotlin.game.tankwar2.interfaces.*

/**砖墙。*/
class BrickWall(
	x: Int,
	y: Int
) : Terrain(x, y), Sufferable, Blockable, Destroyable {
	override var health: Int = 3
	
	override fun draw() {
		Painter.drawImage("img/wall.gif", x, y)
	}
	
	override fun onSuffer(other: Attackable, entities: MutableList<Entity>) {
		health -= other.attack
		runCatching { Composer.play("/hit.wav") }
		entities += Blast(x, y)
	}
	
	override fun isDestroyed(): Boolean {
		return health <= 0
	}
}
